package com.sgb.kjwl.viewmodel.transport;

import android.util.Log;

import com.google.gson.Gson;
import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.model.entity.transport.GoodsInfoTypeEntity3;
import com.sgb.kjwl.model.entity.transport.MapCarsSourcesEntity;
import com.sgb.kjwl.model.entity.transport.MapLongAndLatEntity;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.kjwl.repository.TransportRepertory;
import com.sgb.kjwl.view.ui.activity.transport.MapCarActivity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;

import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MapCarModel extends BaseViewModel {
    private MapCarActivity activity;
    private TransportRepertory repertory;
//    private int page = 1;
//    private int size = 10;
//    public int total;
//
    public MapCarModel(MapCarActivity activity, TransportRepertory repertory) {
        this.activity = activity;
        this.repertory = repertory;
    }
//
//    public void getAddressModel() {
//        DialogHelper.showProgressDialog(activity, null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(true);
//        APIManager.getInstance().getGoodsAPI().getCityList().enqueue(new Callback<BaseEntity<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>>> call, Response<BaseEntity<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>>> response) {
//                DialogHelper.dismissProgressDialog();
//                activity.initAddressData(response.body().getData());
//            }
//
//            @Override
//            public void onFailure(Call<BaseEntity<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>>> call, Throwable t) {
//                DialogHelper.dismissProgressDialog();
//            }
//        });
//    }
//
//    public void getLL(String provinceNo,String cityNo,String districtNo){
//        APIManager.getInstance().getDriverAPI().getLocationLL(repertory.getAreaCode(),provinceNo,cityNo,districtNo).enqueue(new Callback<BaseEntity<MapLongAndLatEntity>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<MapLongAndLatEntity>> call, Response<BaseEntity<MapLongAndLatEntity>> response) {
//                if (response.body() == null) return;
//
//                if (response.body().getState().equals("ok")) {
//                    activity.getLL(response.body().getData());
//                } else {
////                    MToast.showToast(activity, response.body().getMsg());
//                }
//            }
//            @Override
//            public void onFailure(Call<BaseEntity<MapLongAndLatEntity>> call, Throwable t) {
//            }
//        });
//    }
//
//    public void getRadiusList(){
//        APIManager.getInstance().getDriverAPI().getRadiusList().enqueue(new Callback<BaseEntity<List<GoodsInfoTypeEntity3>>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<List<GoodsInfoTypeEntity3>>> call, Response<BaseEntity<List<GoodsInfoTypeEntity3>>> response) {
//                if (response.body() == null) return;
//
//                if (response.body().getState().equals("ok")) {
//                    activity.getRadiusList(response.body().getData());
//                } else {
////                    MToast.showToast(activity, response.body().getMsg());
//                }
//            }
//            @Override
//            public void onFailure(Call<BaseEntity<List<GoodsInfoTypeEntity3>>> call, Throwable t) {
//            }
//        });
//    }
//
//    public void getMapList(String l,String t,String d){
//        APIManager.getInstance().getDriverAPI().getMapCarsSourcesList(repertory.getAreaCode(), l, t, d).enqueue(new Callback<BaseEntity<List<MapCarsSourcesEntity>>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<List<MapCarsSourcesEntity>>> call, Response<BaseEntity<List<MapCarsSourcesEntity>>> response) {
//                if (response.body() == null) return;
//
//                if (response.body().getState().equals("ok")) {
//                    Log.v("responsBody===",new Gson().toJson(response.body().getData()));
//                    activity.showMapList(response.body().getData());
//                } else {
////                    MToast.showToast(activity, response.body().getMsg());
//                }
//            }
//            @Override
//            public void onFailure(Call<BaseEntity<List<MapCarsSourcesEntity>>> call, Throwable t) {
//            }
//        });
//    }

}
